package com.win.controller.mysql;

import com.win.pojo.User;
import com.win.service.UserService;
import com.win.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("users")
@CrossOrigin
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("checkUser")
    public Result checkUser(String username){
        Result result = userService.checkUser(username);
        return result;
    }

    @PostMapping("register")
    public Result register(@RequestBody User user){
        Result result = userService.register(user);
        return result;
    }

    @PostMapping("login")
    public Result login(@RequestBody User user){
        Result result = userService.login(user);
        return result;
    }

    @GetMapping("getUserInfo")
    public Result<User> getUserInfo(@RequestHeader String token){
        Result result = userService.getUserInfo(token);
        return result;
    }


}
